<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
     <title>中华健身俱乐部</title>
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
    <META HTTP-EQUIV="Expires" CONTENT="0">
    <link rel="stylesheet" type="text/css" href="/static/new_ui/new_css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="/static/new_ui/new_css/base_v3.0.css">
    <link rel="stylesheet" type="text/css" href="/static/new_ui/new_css/themes.css">
    <link rel="stylesheet" type="text/css" href="/static/new_ui/new_css/colpick.css">
    <link href="http://ui.fcstatic.naryou.cn/static/libs/easyui/themes/icon.css" rel="stylesheet" type="text/css" />
    <link  style="width:16px; height=16px;" rel="shortcut icon" href="/static/new_ui/images/logo_s.png">
    <script type="text/javascript" src="/static/new_ui/new_js/jquery.js"></script>
    <script type="text/javascript" src="/static/libs/easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="/static/new_ui/new_js/base_v3.0.js"></script>
    <script type="text/javascript" src="/static/new_ui/new_js/bootstrap.min.js"></script>
    <script type="text/javascript" src="/static/new_ui/new_js/build.js"></script>
    <script type="text/javascript" src="/static/new_ui/new_js/css3-mediaqueries.js"></script>
    <script type="text/javascript" src="/static/new_ui/new_js/themes.plugin.js"></script>
    <link rel="stylesheet" type="text/css" href="/static/new_ui/new_css/datepicker.css">
    <script type="text/javascript" src="/static/new_ui/new_js/datepicker.js"></script>
    <script type="text/javascript" src="/static/new_ui/new_js/pagelation.js"></script>
    <script type="text/javascript" src="/static/new_ui/new_js/zepto.touchwipe.min.js"></script>
    <script type="text/javascript" src="/static/new_ui/new_js/colpick.js"></script>
    <script type="text/javascript">
    $.extend({ //jquery extend
        turnOnAjax: function(flag, str) {

            var html = "<div class='modal-backdrop fade in' id='ajaxloadimg' style='z-index:20000'><center><img src='/static/new_ui/img/ajaxloadimg.gif' style='margin: auto;width: 50px;margin-top: 20%;'><p style='color: white;font-weight: bold;'>" + str + "</p></center></div>"
            if (flag == 'on') {
                $("body").append(html)
            } else {
                $("#ajaxloadimg").remove();
            }
        },
    });
    </script>
</head>

<body>
    <div class="container-fluid warp tops">
        <h1 class="page-headers no-icon no-border">添加记录</h1>
        <div class="row-fluid" style="margin-top:-10px">
            <ul id="myTab" class="nav nav-tabs">
            </ul>
            <div id="myCustom" class="tab-content">
                <div class="tab-pane fade in active add-record" style="min-width:1114px;">
                    <div class="right-btn margintop56">
                        <a class="button btn-success btn-w100 btn-h30" href="#addCustomer" onclick="clearMyData()" data-toggle="modal">添加客户</a>
                    </div>
                    <form id="form1" name="form1" id="customerAddForm" action="http://user.lsklf.com:80//merse/appointment/member/" method="post">
                        <input type="hidden" name="currentPage" id="currentPage" value="1" />
                        <input type="hidden" name="orderBy" id="orderBy" value="" />
                        <input type="hidden" name="desc_or_asc" id="desc_or_asc" value="" />
                        <div class="search-content search-w170" style="width:140px;">
                            <input type="text" class="search-input input-w140" placeholder="搜索姓名/手机号" name="customerInfo" id="customerInfo" value="" style="border-color: rgb(203, 207, 210);">
                            <a onclick="submitForm()" href="javascript:void(0)"><em class="search-em"></em></a>
                        </div>
                        <div class="dropdown-list" style="width:106px;">
                            <div class="drop-list drop-list-min" style="width: 80px">
                                <input type="hidden" name="shareSourse" id="shareSourse" value="">
                                <input type="hidden" name="shareSourseName" id="shareSourseName" value="">
                                <div class="checked" style="width: 80px; height: 28px">
                                    <a href="javascript:void(0);">
                                     来源
                                        </a><span></span>
                                </div>
                            </div>
                            <ul class="select select-min none" style="width: 104px;">
                                <li><a href="javascript:void(0);" onclick="$('#shareSourse').val('');$('#shareSourseName').val('');submitForm()">不限</a></</li>
                                    <li><a href="javascript:void(0);" onclick="$('#shareSourse').val('12');$('#shareSourseName').val('客立方来电');submitForm()">客立方来电</a></</li>
                                        <li><a href="javascript:void(0);" onclick="$('#shareSourse').val('13');$('#shareSourseName').val('客立方到访');submitForm()">客立方到访</a></</li>
                            </ul>
                        </div>
                        <div class="dropdown-list" style="width:106px;">
                            <div class="drop-list drop-list-min" style="width: 80px">
                                <input type="hidden" name="consultantid" id="consultantid" value="">
                                <input type="hidden" name="consultantName" id="consultantName" value="">
                                <div class="checked" style="width: 80px; height: 28px">
                                    <a href="javascript:void(0);">
                                        置业顾问
                                        </a><span></span>
                                </div>
                            </div>
                            <ul class="select select-min none" style="width: 104px;">
                                <li><a href="javascript:void(0);" onclick="$('#consultantid').val('');$('#consultantName').val('');submitForm()">不限</a></</li>
                                    <li><a href="javascript:void(0);" onclick="$('#consultantid').val('-1');$('#consultantName').val('无归属');submitForm()">无归属</a></</li>
                                        <li><a href="javascript:void(0);" onclick="$('#consultantid').val('4642');$('#consultantName').val('维尼');submitForm()">维尼</a></</li>
                                            <li><a href="javascript:void(0);" onclick="$('#consultantid').val('4638');$('#consultantName').val('王圣学');submitForm()">王圣学</a></</li>
                                                <li><a href="javascript:void(0);" onclick="$('#consultantid').val('4417');$('#consultantName').val('梁宁');submitForm()">梁宁</a></</li>
                                                    <li><a href="javascript:void(0);" onclick="$('#consultantid').val('4194');$('#consultantName').val('梁先森');submitForm()">梁先森</a></</li>
                                                        <li><a href="javascript:void(0);" onclick="$('#consultantid').val('2948');$('#consultantName').val('段琳钰');submitForm()">段琳钰</a></</li>
                            </ul>
                        </div>
                        <div class="dropdown-list" style="width:106px;">
                            <div class="drop-list drop-list-min" style="width: 80px">
                                <input type="hidden" name="saleTeamid" id="saleTeamid" value="">
                                <input type="hidden" name="saleTeamName" id="saleTeamName" value="">
                                <div class="checked" style="width: 80px; height: 28px">
                                    <a href="javascript:void(0);"> 
                                
                                        
                                        销售组
                                    
                                </a><span></span>
                                </div>
                            </div>
                            <ul class="select select-min none" style="width: 104px;">
                                <li><a href="javascript:void(0);" onclick="$('#saleTeamid').val('');$('#saleTeamName').val('');submitForm()">不限</a></</li>
                                    <li><a href="javascript:void(0);" onclick="$('#saleTeamid').val('249');$('#saleTeamName').val('销售一组');submitForm()">销售一组</a></li>
                            </ul>
                        </div>
                    </form>
                    <table class="table">
                        <tr>
                            <th>姓名/手机号</th>
                            <th>备注名</th>
                            <th>来源</th>
                            <th><a class="sort" href="javascript:void(0);" onclick="sort('DESC')">拓客时间<span></span></a></th>
                            <th>置业顾问</th>
                            <th>所属销售组</th>
                            <th>操作</th>
                        </tr>
                    </table>
                </div>
            </div>
        </div>
        <!-- 分页 -->
        <!---------添加客户弹出层---->
        <script type="text/javascript" src="/static/new_ui/js/jsDialog.js"></script>
        <script type="text/javascript" src="/static/libs/easyui/jquery.easyui.validator.js"></script>
        <!--添加客户弹出层------->
        <form id="add_form">
            <div id="addCustomer" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                    <h3 class="PopupTitle">添加客户</h3>
                </div>
                <div class="modal-body add-customer">
                    <h3 style="margin-top:10px">新客户资料</h3>
                    <div class="input-cont2">
                        <p>
                            <span class="clip-popup-font w85 color-0">手机号: </span>
                            <input type="text" onfocus="hideTips('tips1')" id="mobile" onblur="checkMobile(this.value)" name="mobile" class="in-text2 wrong h30 w220" maxlength="11"><span class="value-wrong2 tips1"></span>
                        </p>
                    </div>
                    <div class="input-cont2">
                        <p>
                            <span class="clip-popup-font w85 color-0">备注名 : </span>
                            <input type="text" name="remarkName" id="remarkName" maxlength="10" class="in-text2 wrong h30 w220" onfocus="hideTips('tips-remarkName')"><span class="value-wrong2 tips-remarkName"></span>
                        </p>
                    </div>
                    <!------单选按钮------------->
                    <div class=" input-cont2">
                        <p class="radios-module">
                            <span class="clip-popup-font w85 color-0">来源类型 : </span>
                            <input type="hidden" class="radio-value" name="type" value="1" />
                            <a class="radios first-radio current" data-value="1" href="javascript:void(0);"><span></span>&nbsp;<span>来电</span></a>
                            <a class="radios second-radio FChoose" data-value="2" href="javascript:void(0);"><span></span>&nbsp;<span>到访</span></a>
                        </p>
                    </div>
                    <div class="input-cont2">
                        <p class="add-call-time">
                            <span class="clip-popup-font w85 color-0"><span id="visitType">来电</span>时间 : </span>
                            <input type="text" name="time" class="w220 h30" id="visitDate" value=""><em class="Icon2"></em>
                        </p>
                    </div>
                    <h3 class="add-customer-record">分配置业顾问</h3>
                    <span class="add-customer-choice">(选填)</span>
                    <div class="input-cont2">
                        <div>
                            <span class="clip-popup-font w85 color-0">销售组 : </span>
                            <div class="dropdown-list w220 h30" style="height:30px">
                                <div class="drop-list  w220 h30">
                                    <div class="checked w220 h30"><a href="javascript:void(0);">--无--</a><span></span></div>
                                </div>
                                <ul class="select  none w220 ">
                                    <li><a href="javascript:void(0);" onclick="chooseConsultant(-1)">--无--</a></li>
                                    <li><a href="javascript:void(0);" onclick="chooseConsultant('249')">销售一组</a></li>
                                </ul>
                            </div>
                        </div>
                    </div>
                    <div class="input-cont2">
                        <div>
                            <span class="clip-popup-font w85 color-0">置业顾问 : </span>
                            <div class="dropdown-list w220 h30" style="height:30px">
                                <div class="drop-list  w220 h30">
                                    <input name="consultantId" id="consultantId" type="hidden" value="" />
                                    <div class="checked w220 h30" id="defaultOne"><a href="javascript:void(0);" onclick="setConsultantId('')">--无--</a><span></span></div>
                                </div>
                                <ul class="select  none w220" id="consultants">
                                    <li><a href="javascript:void(0);">--无--</a></li>
                                </ul>
                            </div>
                        </div>
                    </div>
                    <h3 class="add-customer-record">记录客带客关系</h3>
                    <span class="add-customer-choice">(选填)</span>
                    <span class="add-customer-icon">
            <!----弹出层------>
        <div class="add-customer-popup">
            <span class="iocn"></span>
                    <p>比如：</p>
                    <p>新客户A是老客户B推荐的，</p>
                    <p>为了让“客立方”记录新客户A与老客户B的客带客关系，便于日后获取佣金奖励，可填写老客户B的手机号即可。</p>
                </div>
                </span>
                <div class="input-cont2">
                    <p>
                        <span class="clip-popup-font w85 color-0">老客户手机号 : </span>
                        <input type="text" name="shareMobile" id="shareMobile" onfocus="hideTips('tips2')" onblur="checkOldMobile(this.value)" class="in-text2 wrong h30 w220" maxlength="11"><span class="value-wrong2 tips2"></span>
                    </p>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="button btn-success btn-w100 clip-save" onclick="saveSubmit(this)">确认添加</button>
                <button type="button" class="button btn-gray btn-w100" data-dismiss="modal" aria-hidden="true">取消</button>
            </div>
    </div>
    </form>
    <script type="text/javascript" src="/static/libs/util.js"></script>
    <script>
    //根据职业顾问销售组查找职业顾问
    function chooseConsultant(orgId) {
        $("#consultantId").val("");
        $("#defaultOne").html('<a href="javascript:void(0);" onclick="setConsultantId(\'\')">--无--</a>');
        $("#consultants").empty();
        if (orgId < 0) {
            $("#consultants").html('<li><a href="javascript:void(0);">--无--</a></li>');
            return;
        }
        var url = "/merse/appointment/member/consultant";
        $.ajax({
            url: url,
            type: 'get',
            data: $.param({
                orgId: orgId
            }, true),
            success: (function(data) {
                var consultants = data.consultantList;
                var html = '';
                for (var i in consultants) {
                    var consultant = consultants[i];
                    html += '<li><a href="javascript:void(0);" onclick="setConsultantId(' + consultant.id + ')">' + consultant.name + '</a></li>';
                }
                $("#consultants").html(html);
            })
        });
    }

    function setConsultantId(consultantId) {
        $("#consultantId").val(consultantId);
    }

    //验证手机号是否存在，该客户是否还可以被推荐到该楼盘
    function checkMobile(mobile) {
        var url = "/merse/appointment/member/checkMobile";
        if (!isMobel(mobile)) {
            $(".tips1").html("请输入有效手机号！").css('display', 'inline-block');
            return;
        }
        $.ajax({
            url: url,
            type: 'get',
            data: $.param({
                mobile: mobile
            }, true),
            success: (function(data) {
                if (data) {
                    $(".tips1").html("该手机号已存在，不能再被添加！").css('display', 'inline-block');
                }
            })
        });
    }

    function checkOldMobile(mobile) {
        var url = "/merse/appointment/member/checkOldMobile";
        if (mobile != "") {
            $.ajax({
                url: url,
                type: 'get',
                data: $.param({
                    mobile: mobile
                }, true),
                success: (function(data) {
                    if (!data) {
                        $(".tips2").html("该老客未注册，请确认已注册！").css('display', 'inline-block');
                    }
                })
            });
        }
    }

    function hideTips(obj) {
        $("." + obj).html("").css('display', 'none');
    }

    function isMobel(value) {
        if (value.match(/^1[3|4|5|6|7|8]\d{9}$/)) {
            return true;
        } else {
            return false;
        }
    }
    $(function() {
        $(".radios-module .radios").on('click', function() {
            var r_value = $(this).attr('data-value');
            if (r_value == 1) {
                $("#visitType").html("来电");
            }
            if (r_value == 2) {
                $("#visitType").html("到访");
            }
            $(this).parents().find('.radio-value').val(r_value);
        });
    });

    function saveSubmit(obj) {
        if (!isMobel($("#mobile").val())) {
            saveResult(0, "请输入有效手机号！");
            return;
        }
        if ($("#shareMobile").val() != "") {
            if (!isMobel($("#shareMobile").val())) {
                saveResult(0, "老客户手机号无效！");
                return;
            }
        }
        if ($("#remarkName").val().length < 2) {
            saveResult(0, "请输入2-10位备注名！");
            return;
        }
        var url = "/merse/appointment/member/save";
        $.post(url, $('#add_form').serialize(), function(data) {
            if (data.status == "SUCCESS") {
                statusInfo($(obj), 1, "保存成功");
                document.getElementById('form1').submit();
            } else {
                saveResult(0);
            }
        }, "json");
    }

    $(function() {
        $('#visitDate').DatePicker({
            format: 'Y-m-d',
            date: new Date().toLocaleDateString(),
            current: $('#visitDate').val(),
            starts: 1,
            position: 'bottom',
            onBeforeShow: function() {
                $('#visitDate').DatePickerSetDate(new Date().toLocaleDateString(), true);
            },
            onChange: function(formated, dates) {
                $('#visitDate').val(formated);
                $('#visitDate').DatePickerHide();
                $('#visitDate').focus();
            }
        });
    });
    </script>
</body>
<script>
$(function() {
    //init加载数据
    loaddata();
});

function submitForm() {
    $("#myCustom").find("#form1").find("#currentPage").val('1');
    $("#myCustom").find("#form1").submit();
}

//翻页
function doJumpPage(currentpage) {

    $("#myCustom").find("table").find(".querydata").remove();

    //js控制分页
    var current = parseInt(currentpage);
    var total = parseInt($(".paging .total-num").text());
    if (total <= current) {
        $(".paging .page-down").removeAttr("onclick");
        current = total;
    } else {
        $(".paging .page-down").attr("onclick", "doJumpPage('" + (current + 1) + "')");
    }
    if (current <= 1) {
        $(".paging .page-up").removeAttr("onclick");
        current = 1;
    } else {
        $(".paging .page-up").attr("onclick", "doJumpPage('" + (current - 1) + "')");
    }
    $(".paging .first-num").text(current);
    $(".paging #jumpPageVal").val(current);
    $(".paging button").attr("onclick", "doJumpPageRedirect('" + current + "')");
    $("#form1").find("#currentPage").val(current);
    //init加载数据
    loaddata();

}

function doJumpPageRedirect(current) {
    doJumpPage($(".paging #jumpPageVal").val());
}

function loaddata() {
    var root = 'http://user.lsklf.com:80/';
    $.post(
        root + "/merse/appointment/member/data",
        $("#form1").serialize(),
        function(list) {

            var str = "";
            if (list != null && list.length != 0) {

                for (var int = 0; int < list.length; int++) {
                    var customer_name = list[int].customer_name;
                    var customer_phone = list[int].customer_phone;
                    var remark_name = list[int].remark_name;
                    var sharesource = list[int].sharesource;
                    var create_time = list[int].create_time;
                    var consultant_name = list[int].consultant_name;
                    var consultant_phone = list[int].consultant_phone;
                    var belong_saleTeam = list[int].belong_saleTeam;

                    if (customer_name === 'null' || customer_name === null || customer_name === 'undefined') {
                        customer_name = '';
                    }
                    if (customer_phone === 'null' || customer_phone === null || customer_phone === 'undefined') {
                        customer_phone = '';
                    }
                    if (remark_name === 'null' || remark_name === null || remark_name === 'undefined') {
                        remark_name = '';
                    }
                    if (sharesource === 'null' || sharesource === null || sharesource === 'undefined') {
                        sharesource = '';
                    }
                    if (create_time === 'null' || create_time === null || create_time === 'undefined') {
                        create_time = '';
                    }
                    if (consultant_name === 'null' || consultant_name === null || consultant_name === 'undefined') {
                        consultant_name = '';
                    }
                    if (consultant_phone === 'null' || consultant_phone === null || consultant_phone === 'undefined') {
                        consultant_phone = '';
                    }
                    if (belong_saleTeam === 'null' || belong_saleTeam === null || belong_saleTeam === 'undefined') {
                        belong_saleTeam = '';
                    }

                    str += "<tr class='querydata'><td><a class='pass color-green' href='/merse/consumer/detail/" + list[int].userid + "/1'><span class='name'>" + customer_name + "</span><span class='phone-num'>" + customer_phone + "</span></a></td>" +
                        "<td>" + remark_name + "</td>" +
                        "<td>" + sharesource + "</td>" +
                        "<td>" + create_time + "</td>" +
                        "<td><span class='name'>" + consultant_name + "</span><span class='phone-num'>" + consultant_phone + "</span></td>" +
                        "<td>" + belong_saleTeam + "</td>" +
                        "<td><a class='pass color-green' href='/merse/consumer/detail/" + list[int].userid + "/1'>客户详情</a></td>" +
                        "</tr>";
                }
                $("#myCustom").find("table").append(str);
            } else {

                $("#myCustom").append("<div class='no-data' style='text-align:center;width: 100%;height:400px;background-color: #fff;border-bottom:1px solid #EAEDEE;border-left:1px solid #EAEDEE;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;'><img style='margin:110px 0 35px 0' src='/new/images/undefined-data.png' /><p style='color:#bec4c4'>暂时还没有数据!</p></div>")
            }
        }

    );
}

function sort(sortmethod) {
    $("#myCustom").find("#form1").find("#currentPage").val('1');
    $("#myCustom").find("form").find("#orderBy").val("m.create_date");
    $("#myCustom").find("form").find("#desc_or_asc").val(sortmethod);
    $("#myCustom").find("form").submit();
}

function clearMyData() {
    $("#addCustomer").find(".in-text2").val("");
    var date = new Date().format('yyyy-MM-dd');
    $("#visitDate").val(date);
}
</script>

</html>
